package com.yfp.operation.result;

import lombok.Data;

import java.util.Optional;

@Data
public class FuResult<S,C,P> {
    // 状态
    private S status;
    // 错误代码
    private Optional<C> errorCode;
    // 信息
    private Optional<String> message;
    // 数据
    private Optional<P> payload;

    public FuResult(S status) {
        this.status = status;
        this.message = Optional.empty();
        this.errorCode = Optional.empty();
        this.payload = Optional.empty();
    }

    public FuResult(S status, String message) {
        this.status = status;
        this.errorCode = Optional.empty();
        this.message = Optional.ofNullable(message);
        this.payload = Optional.empty();
    }


    public FuResult(S status, C errorCode, String message) {
        this.status = status;
        this.errorCode = Optional.ofNullable(errorCode);
        this.message = Optional.ofNullable(message);
        this.payload = Optional.empty();
    }

    public FuResult(S status, C errorCode, String message, P payload) {
        this.status = status;
        this.errorCode = Optional.ofNullable(errorCode);
        this.message = Optional.ofNullable(message);
        this.payload = Optional.ofNullable(payload);
    }


}
